import ai

def tohexstr(int_val):
    return hex(int_val)[2:].upper()

def strhex(strval):
    h="0123456789abcdef"
    neg = False
    if strval[0]=='-':
        neg = True
        strval = strval[1:]

    l = len(strval)-1
    val = 0
    for c in strval.lower():
        val += h.index(c)*16**l
        l -= 1
    if neg:
        return -val
    else:
        return val
